package train48days;
import java.util.*;
public class RationalArithmetic {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){

            String l = sc.next();
            String r = sc.next();

            int lLine = findLine(l);
            int rLine = findLine(r);

            Fraction fl = new Fraction(getMolecular(l,lLine),getDenominator(l,lLine));
            Fraction fr = new Fraction(getMolecular(r,rLine),getDenominator(r,rLine));

            add(fl,fr);

            sub(fl,fr);

            mul(fl,fr);

            div(fl,fr);
        }
    }

    private static void div(Fraction l,Fraction r){
        if(r.up == 0){
            print(l,r,0,0,'/',true);
        }else{
            mul(l,r.down,r.up,'/');
        }
    }

    private static void mul(Fraction l,Fraction r){
        mul(l,r.up,r.down,'*');
    }

    private static void mul(Fraction l,long rUp,long rDown,char ch){
        long down = l.down * rDown;
        long up = l.up * rUp;
        if(down < 0){
            down *= -1;
            up *= -1;
        }
        if(ch == '/'){
            long temp = rUp;
            rUp = rDown;
            rDown = temp;
        }
        print(l,new Fraction(rUp,rDown),up,down,ch,false);
    }

    private static void sub(Fraction l,Fraction r){
        add(l,r,-1);
    }

    private static void add(Fraction l,Fraction r){
        add(l,r,1);
    }

    private static void add(Fraction l,Fraction r,int n){
        long down = l.down * r.down;
        long up = l.up * r.down + (r.up * l.down) * n;
        print(l,r,up,down,n == 1 ? '+' : '-',false);
    }

    private static void print(Fraction l,Fraction r,long up,long down,char ch,boolean isInf){
        System.out.println(doSimple(l.up,l.down)+" "+ch+" "+doSimple(r.up,r.down)+" = "+(isInf ? "Inf" : doSimple(up,down)));
    }

    private static String doSimple(long up,long down){
        if(up == 0){
            return "0";
        }
        if(up % down == 0){
            long temp = up / down;
            return temp > 0 ? temp + "" : "("+temp+')';
        }
        boolean isNeg = false;
        if(up < 0){
            up *= -1;
            isNeg = true;
        }
        long common = maxCommon(up,down);
        if(common != -1){
            up /= common;
            down /= common;
        }
        if(up > down){
            long temp = up / down;
            up %= down;
            if(isNeg){
                return "(-"+temp+" "+up+'/'+down+')';
            }
            return temp+" "+up+'/'+down;
        }
        if(isNeg){
            return "(-"+up+'/'+down+')';
        }
        return up + "/" + down;
    }

    private static long maxCommon(long up,long down){
        long common = -1;
        if(up > down){
            long temp = up;
            up = down;
            down = temp;
        }
        for(long i = up;i >1;i--){
            if(down % i == 0 && up % i == 0){
                common = i;
                break;
            }
        }
        return common;
    }

    private static class Fraction{
        private long up;
        private long down;
        public Fraction(long up,long down){
            this.up = up;
            this.down = down;
        }
    }

    private static int findLine(String str) {
        int i = 0;
        for(;i < str.length();i++){
            if(str.charAt(i) == '/'){
                break;
            }
        }
        return i;
    }
    private static long getMolecular(String str,int index){
        int molecular = 0;
        for(int i = index - 1;i >= 0;i--){
            char ch = str.charAt(i);
            if(ch >= '0' && ch <= '9'){
                molecular = molecular * 10 + (ch - '0');
            }else{
                if(ch == '-'){
                    molecular *= -1;
                }
                break;
            }
        }
        return molecular;
    }
    private static long getDenominator(String str,int index){
        int denominator = 0;
        for(int i = index + 1;i < str.length();i++){
            char ch = str.charAt(i);
            if(ch >= '0' && ch <= '9'){
                denominator = denominator * 10 + (ch - '0');
            }else{
                break;
            }
        }
        return denominator;
    }
}
